function Character(/*tile*/ tile, /*vec2*/ position){
	this.tile = tile;
	this.position = position;
	this.mapManager = null;
	this.isNPC = true;
};

Character.prototype.moveTo = function(/*vec2*/ position){
	this.position.sum(position);
	
	var solid = this.mapManager.isSolid(this.position.a, this.position.b);
	if (solid == 2){
		if (!this.mapManager.crossDoor(this, position))
			solid = 1;
	}
	
	if (solid == 1){
		position.multiply(-1);
		this.position.sum(position);
		return false;
	}else if (solid == 0){
		var npc = null;
		if (this.isNPC){
			npc = (this.mapManager.player.position.equals(this.position))? this.mapManager.player : null;
		}else{
			npc = this.mapManager.getNPCAt(this.position);
		}
		
		if (npc != null){
			position.multiply(-1);
			this.position.sum(position);
			return false;
		}
	}
	
	return true;
};

Character.prototype.draw = function(){
	var game = this.mapManager.game;
	
	game.drawTile(this.tile, this.position.a - this.mapManager.view.a, this.position.b - this.mapManager.view.b);
};
